home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Disc to the Future 2
/
Disc to the Future Part II Programmer's Reference (Wayzata Technology)(6013)(1992).bin
/
MAC
/
OTHER_LA
/
YERK__
/
TOOLBOX_
/
READPORT.1
< prev
next >
Wrap
Text File
|
1990-08-15
|
3KB
|
117 lines
\ 6.10.87 rfl modified to support backspace and paste
\ 6.3.87 rfl Sends a text file to a Forth Board. Tabs are converted to
\ spaces.
\ 4/19/87 rfl removed most of switcher setup to relect telescope arch.
\ this means no outputqueue and no polling
\ 10.1.87 rfl added next: fevent to timeoutwait
\ 10.8.87 rfl above fix caused problems with searcher on abort.... removed
\ 1.1.88 rfl general cleanup
\ 6.22.88 rfl changed to class xPort for same methods to printer
\ 7.1.88 rfl took out next: fevent because of suspected problems with dlg
\ 7.11.88 rfl changed nullproc to assembly and took out pnullproc
\ 9.17.88 rfl remove link and endlink
\ 8.13.90 rfl modified term and removed ackword stuff
create nullProc $ 4e75 w,
0 value charflag
0 variable theChar
:PROC doChr true -> charflag ;PROC
\ necessary to scroll since '13 emit' is not identical to 'cr'
( char -- )
: .keys 4 tmode
CASE
8 OF (bs) ENDOF
0 12 RANGEOF ENDOF
13 OF cr ENDOF
emit 0
ENDCASE 0 tmode ;
\ 0 variable ackWord \ just a location to throw in acknowledgments
:CLASS ReadPort <super port
timer myTimer
int TimeOutTime \ a value of 4 is marginal, 5 seems to work ok
var myAction
var myNullProcCfa
:M putTimeOut: put: timeOutTime ;M
:M actions: put: myAction ;M
:M putProc: put: myNullProcCfa ;M
:M killRead: get: myNullProcCfa +base ^base 24 + ! kill: super drop ;M
:M classInit: nullcfa put: myAction 6 put: timeOutTime ;M
\ waits for an acknowledge or times out. 'time' is in 60ths of a second
\ returns non-zero if an error condition exists
:M timeOutWait: { time \ flag -- tf }
start: myTimer false -> flag
BEGIN get: myTimer time >
IF killread: self exec: myAction true -> flag THEN
\ next: fevent IF 2drop THEN
result: self not
UNTIL flag ;M
\ ( -- tf)
\ :M waitForAck: get: myNullProcCfa
\ ackword 1 readnw: self drop get: timeOutTime timeoutwait: self ;M
:M term: { oPort \ myChar -- } 0 -> myChar 0 -> charflag
BEGIN result: self 0=
IF charFlag 0=
IF 'c doChr theChar 1 readnw: self drop
ELSE 0 -> charflag thechar c@ .keys
THEN
ELSE result: self 0<
IF result: self . abort" =read error" THEN
THEN
?terminal
IF key -> myChar myChar ascii | <>
IF myChar 8 =
IF 127 ELSE myChar THEN
put: oPort
THEN
THEN
myChar ascii | =
UNTIL kill: self drop ;M
;CLASS
port iwout port pwout
0 1 init: iwout 1 1 init: pwout
2 8 0 config: iwout 2 8 0 config: pwout
2400 baud: iwout 19200 baud: pwout
readPort iwin \ instantiate input port
0 0 init: iwin \ modem port
2 8 0 config: iwin \ 2 stop, 8 data, no parity
2400 baud: iwin
'c nullProc putProc: iwin
ReadPort pwin \ instantiate input port
1 0 init: pwin \ printer port
2 8 0 config: pwin \ 2 stop, 8 data, no parity
19200 baud: pwin
'c NullProc putProc: pwin
: term iwout term: iwin ;
: pterm pwout term: pwin ;
: iOpen open: iwout open: iwin reset: iwin 2drop ;
: pOpen open: pwout open: pwin reset: pwin 2drop ;
: start iOpen pOpen ;
: pWrite write: pwout drop ;
: pWriteCr pWrite 13 put: pwout ;
: crp 13 put: pwout ;